/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SearchResultsView.java
 *
 * Created on Apr 10, 2010, 5:12:03 PM
 */

package ticketmaster.presentation.customer.purchase;

import java.util.Collection;
import javax.swing.JTable;
import ticketmaster.dataobject.EventView;
import ticketmaster.presentation.customer.CustomerBasePanel;

/**
 *
 * @author Wei Liu
 */
public class SearchResultsView extends CustomerBasePanel {

    /** Creates new form SearchResultsView */
    public SearchResultsView(Collection<EventView> events) {
        initComponents();
        initTable(events);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        btnNext = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(ticketmaster.TicketMasterApp.class).getContext().getResourceMap(SearchResultsView.class);
        setBackground(resourceMap.getColor("Form.background")); // NOI18N
        setName("Form"); // NOI18N
        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N
        add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 25, -1, -1));

        btnNext.setFont(resourceMap.getFont("jButton1.font")); // NOI18N
        btnNext.setText(resourceMap.getString("btnNext.text")); // NOI18N
        btnNext.setName("btnNext"); // NOI18N
        btnNext.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNextActionPerformed(evt);
            }
        });
        add(btnNext, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 550, 140, 40));

        jButton1.setFont(resourceMap.getFont("jButton1.font")); // NOI18N
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(23, 550, 140, 40));
    }// </editor-fold>//GEN-END:initComponents

    private void btnNextActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnNextActionPerformed
    {//GEN-HEADEREND:event_btnNextActionPerformed
        JTable dataTable = table.getTable();
        EventView eventView = (EventView) dataTable.getValueAt(dataTable.getSelectedRow(), 0);
        //SeatSelectionView ssv = new SeatSelectionView(eventView);
        SeatsSelectionView ssv = new SeatsSelectionView(eventView);
        this.getPnlParent().removeAll();
        this.getPnlParent().add(ssv);
        this.getPnlParent().validate();
        this.getPnlParent().repaint();
        ssv.setPnlParent(this.getPnlParent());
    }//GEN-LAST:event_btnNextActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed
    {//GEN-HEADEREND:event_jButton1ActionPerformed
        SearchView sv = new SearchView();

        this.getPnlParent().removeAll();
        this.getPnlParent().add(sv);
        this.getPnlParent().validate();
        this.getPnlParent().repaint();
        sv.setPnlParent(getPnlParent());
    }//GEN-LAST:event_jButton1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnNext;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    // End of variables declaration//GEN-END:variables

    private EventTable table;

    private void initTable(Collection<EventView> events)
    {
        table = new EventTable(events);
        add(table, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 100, -1, -1));
    }


}
